package com.myblog.blog.controller;

import java.util.Arrays;
import java.util.Map;

import com.myblog.blog.common.utils.PageUtils;
import com.myblog.blog.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.myblog.blog.entity.ArticlesLabelsSortsEntity;
import com.myblog.blog.service.ArticlesLabelsSortsService;



/**
 * 文章_标签_分类表
 *
 * @author pengyifeng
 * @email pengyifeng@aliyun.com
 * @date 2021-01-02 14:34:18
 */
@RestController
@RequestMapping("blog/articleslabelssorts")
public class ArticlesLabelsSortsController {
    @Autowired
    private ArticlesLabelsSortsService articlesLabelsSortsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("blog:articleslabelssorts:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = articlesLabelsSortsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("blog:articleslabelssorts:info")
    public R info(@PathVariable("id") Integer id){
		ArticlesLabelsSortsEntity articlesLabelsSorts = articlesLabelsSortsService.getById(id);

        return R.ok().put("articlesLabelsSorts", articlesLabelsSorts);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("blog:articleslabelssorts:save")
    public R save(@RequestBody ArticlesLabelsSortsEntity articlesLabelsSorts){
		articlesLabelsSortsService.save(articlesLabelsSorts);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("blog:articleslabelssorts:update")
    public R update(@RequestBody ArticlesLabelsSortsEntity articlesLabelsSorts){
		articlesLabelsSortsService.updateById(articlesLabelsSorts);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("blog:articleslabelssorts:delete")
    public R delete(@RequestBody Integer[] ids){
		articlesLabelsSortsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
